package com.arges.service.impl;

import com.arges.dao.BookDao;
import com.arges.pojo.Book;
import com.arges.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(propagation = Propagation.REQUIRED)
public class BookServiceImpl implements BookService {

    @Autowired
    private BookDao bookDao;

    /**
     * 查询所有
     * @return
     */
    @Override
    public List<Book> findAll(String hql) {
        return bookDao.findAll(hql);
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Override
    public Book getById(Integer id) {
        return bookDao.selectById(id);
    }

    /**
     * 新增
     * @param book
     * @return
     */
    @Override
    public Integer save(Book book) {
        return bookDao.save(book);
    }

    /**
     * 删除
     * @param book
     */
    @Override
    public void delete(Book book) {
        bookDao.delete(book);
    }

    /**
     * 修改
     * @param book
     */
    @Override
    public void update(Book book) {
        bookDao.update(book);
    }
}
